<?php
/**
 * 创建收藏夹
 * 前端获取创建收藏夹的信息
{
 属性：
     * user_id
     * name
     * Introduction
}
 */

session_start();
require_once "./read.php";
//获取当前登陆状态下的用户id
$user_id = $_SESSION['id'];
//获取json数据
if(!empty($_POST)){
    $data = $_POST;
    $data = array(
        "user_id"=>$user_id,
        "name"=>$data['name'],
        "Introduction"=>$data['Introduction']
    );
}else{
    $data = json_decode(file_get_contents("php://input"));
    $data = array(
        "user_id"=>$user_id,
        "name"=>$data->name,
        "Introduction"=>$data->Introduction
    );
}

//创建成功
if($post->Create_Favorites($data)) {
    $result = array(
        "status"=>200,
        "msg"=>"收藏夹创建成功"
    );
}else{
    $result = array(
        "status"=>201,
        "msg"=>"收藏夹创建失败"
    );
}
$res = json_encode($result,JSON_UNESCAPED_UNICODE);
echo $res;
return $res;